<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>旅行日记</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="<?php echo base_url('static/css/bootstrap.min.css'); ?>" rel="stylesheet" media="screen">
    <link href="<?php echo base_url('static/css/style.css'); ?>" rel="stylesheet" media="screen">
    <style type="text/css">
        .error{
            color:red;
        }
        .ok{
            color:green;
        }
    </style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="brand" href="<?php echo base_url("main/index");?>">旅行日记</a>
        </div>
    </div>
</div>

<div class="container">
    <ul class="nav nav-tabs">
        <li><a href="<?php echo base_url("main/index");?>">返回首页</a></li>
        <li class="active"><a href="<?php echo base_url("user_reg/index");?>">注册</a></li>
        <li><a href="<?php echo base_url("user_login");?>">登录</a></li>
    </ul>
    <div class="row-fluid">
        <div class="form">
            <form action="<?php echo base_url("user_reg/index");?>" method="post" class="form-horizontal">
                <div class="control-group">
                    <label for="title">用户名</label>
                    <input type="text" id="username" class="txt" name="username" value="david">
                    <span class="msg_username"></span>
                </div>
                <div class="control-group">
                    <label for="password">密码</label>
                    <input type="text" id="password" class="txt" name="password">
                </div>
                <div class="control-group">
                    <label for="password2">确认密码</label>
                    <input type="text" id="password2" class="txt" name="password2">
                </div>
                <div class="control-group">
                    <label for="email">Email</label>
                    <input type="text" id="email" class="txt" name="email">
                </div>
                <div class="control-group">
                    <button type="submit" name="register" class="btn btn-success" value="提交">提交</button>
                </div>
            </form>
        </div>
        <!--/row-->
        <hr>
        <footer>
            <p>&copy; Copyright 2015 </p>
        </footer>
    </div>
    <script src="<?php echo base_url('static/js/jquery.js');?>"></script>
    <script src="<?php echo base_url('static/js/bootstrap.min.js');?>"></script>

    <script type="text/javascript">
        $('#username').blur(function(){
            $.post('<?php echo site_url("User_reg/ajax_reg");?>',{name:$('#username').val()},function(data){
                console.log(data);
                $('.msg_username').removeClass('error ok');
                if(data.error){
                    $('.msg_username').html(data.msg).addClass('error');
                }else{
                    $('.msg_username').html(data.msg).addClass('ok');
                }
            },'json');

        });
    </script>
</body>
</html>